<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改合同</title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js" ></script>  
<script type="text/javascript" src="js/jquery.autocomplete.js"></script> 
<script type="text/javascript" src="js/crlCheckCommons.js"></script>
<script type="text/javascript" src="js/calendar/WdatePicker.js"></script>
<link   rel="stylesheet" href="css/jquery.autocomplete.css"  /> 
    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <link href="css/font-awesome.min.css" rel="stylesheet" />
    <link href="css/animate.css" rel="stylesheet"  />
    <link href="css/plugins/summernote/summernote.css" rel="stylesheet" />
    <link href="css/plugins/summernote/summernote-bs3.css" rel="stylesheet" />
    <link href="css/style.css" rel="stylesheet" /> 
<style>
		.bor {
	    border: 0px solid #ccc;
				}
		#emptable td{
	border:none !important;
}
td{
	margin:0;
	padding-left:16px;
	border:none;
	text-align:left;
}
.td{
	font-size: 16px;
	border:none;
	text-align:right;
}
#button{
	border-radius:10px;
	margin-left: 10px;
	width: 135px;
	height: 30px;
	border: none;
	font-size: 16px;
	color: #fff;
	background-color: #47a4e1;
}		
        .form-body .col-md-6,
        .form-body .col-md-12 {
            min-height: 400px;
        }
        #apro,#bpro,#cpro{
        	display:none;
        }
        #baBodysubmit{
        	padding-left:90px;
        	margin-top:0;
        }
</style>			
</head>
<body style="background:white" >
	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<img src="img/coin02.png" />
				<span><a href="main.do">首页</a>&nbsp;-&nbsp;<a href="contractmanage.do">合同管理</a>&nbsp;-&nbsp;合同修改</span>
			</div>
		</div>
		<div class="page ">
			<!-- 上传广告页面样式 -->
			<div class="banneradd bor">
				<form:form action="docontractupdate.do" method="post" id="form" modelAttribute="contract" onsubmit="return checkform()">
				<div class="baTopNo">
						<span>编辑合同</span>
					</div>
					<div class="baBody">
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label">合同名称：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="name" class="form-control"
													id="oname" value="${contract.name }"/>
													<input type="hidden" name="id" value="${contract.id }"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">机构名称：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" class="form-control"
													placeholder="请输至少一个汉字" id="autoComplete" value="${organization.name }"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">购买产品类别：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="atype"> <input
													type="checkbox" value="1" id="atype" name="aproduct" <c:if test="${contract.aproduct ==1}">checked=""</c:if>/>网站专区
												</label> <label class="checkbox-inline" for="btype"> <input
													type="checkbox" value="1" id="btype" name="bproduct" <c:if test="${contract.bproduct ==1}">checked=""</c:if>/>微刊
												</label> <label class="checkbox-inline" for="ctype"> <input
													type="checkbox" value="1" id="ctype" name="cproduct" <c:if test="${contract.cproduct ==1}">checked=""</c:if>/>微博</label>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">服务方式：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<label class="radio-inline"> <input type="radio"
													value="1" name="servicetype" checked="" <c:if test="${contract.servicetype ==1}">checked="" </c:if>/>镜像
												</label> <label class="radio-inline"> <input type="radio"
													value="2" name="servicetype" <c:if test="${contract.servicetype ==2}">checked="" </c:if>/>远程
												</label>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同性质：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="purpose">
													<option value="1" selected="selected">新增</option>
													<option value="2">正式</option>
													<option value="3">已签</option>
													<option value="4">续约</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同类型：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="contracttype">
													<option value="1" selected="selected">销售</option>
													<option value="2">采购</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同经办人：</label>
											<div class="col-sm-9">
												<p class="form-control-static" id="cname">${organization.contact.ename}</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同联系人：</label>
											<div class="col-sm-9">
												<p class="form-control-static" id="cename">${organization.contact.name}</p>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同总金额：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="amount" id="amount"
													class="form-control" value="${contract.amount }"/> <span class="help-block m-b-none"></span>

											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">付款方式：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="paytype">
													<option value="1" selected="selected">一次性付款</option>
													<option value="2">按年支付</option>
													<option value="3">分期付款</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">签约日期：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="signdate" id="signdate"
													readonly="readonly" onclick="WdatePicker()"
													value="<fmt:formatDate value="${contract.signdate }" pattern="yyyy-MM-dd" />"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">截止日期：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="deadline" id="deadline"
													readonly="readonly" onclick="WdatePicker()" 
													value="<fmt:formatDate value="${contract.deadline }" pattern="yyyy-MM-dd" />"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">合同日期：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="begindate" id="begindate"
													readonly="readonly" onclick="WdatePicker()" 
													value="<fmt:formatDate value="${contract.begindate }" pattern="yyyy-MM-dd" />"/> 至 <input
													type="text" name="enddate" id="enddate" readonly="readonly"
													onclick="WdatePicker()" 
													value="<fmt:formatDate value="${contract.enddate}" pattern="yyyy-MM-dd" />"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">审核状态：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="checkstate">
													<option value="1" selected="selected">未审核</option>
													<option value="2">审核中</option>
													<option value="3">已审核</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">甲方签字人：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="aset" id="aset"
													class="form-control" value="${contract.aset}"/> <span class="help-block m-b-none"></span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">乙方签字人：<span
												style="color: red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="bset" id="bset"
													class="form-control" value="${contract.bset}"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注信息：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="40" name="remark">${contract.remark}</textarea>
											</div>
										</div>	
									</div>
								</div>
							</div>
						</div>
					</div>	
					<!-- 
					<span>产品信息</span>		
					<!-- ABC产品 -->	
								<!-- A产品 -->
				<div id="apro">
					<div class="baTopNo" >
						<span>网站专区 </span>
					</div>
					<div class="baBody" >
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">网站功能：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="netfunction">
													<c:if test="${fn:contains(contract.producta.netfunction,'1')}">
													<input type="checkbox" value="1" id="netfunction" name="producta.netfunction" checked="" />期刊</c:if>
												</label>
												<label class="checkbox-inline" for="netfunction">
													<c:if test="${fn:contains(contract.producta.netfunction,'2')}">
													<input type="checkbox" value="2" id="netfunction" name="producta.netfunction" checked="" />多媒体</c:if>
												</label>
												<label class="checkbox-inline" for="netfunction">
													<c:if test="${fn:contains(contract.producta.netfunction,'3')}">
													<input type="checkbox" value="3" id="netfunction" name="producta.netfunction" checked="" />下载	</c:if>
												</label>
												
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">开通时间：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.begintime" id="begintime"  readonly="readonly" onclick="WdatePicker()" 
												value="<fmt:formatDate value="${contract.producta.begintime }" pattern="yyyy-MM-dd"  />" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网址：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.html" id="html" class="form-control" value="${contract.producta.html}" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">并发数：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.concurrencylevel" id="concurrencylevel" class="form-control"  value="${contract.producta.concurrencylevel }" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管账号：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.username" id="productc.username" class="form-control" value="${contract.producta.username }" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管密码：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="producta.password" id="productc.password" class="form-control" value="${contract.producta.password }" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="30" name="producta.remark"  >${contract.producta.remark }</textarea>
												<input type="hidden" name="producta.id" value="${contract.producta.id }"/>
												<input type="hidden" name="producta.coid" value="${contract.producta.coid }"/>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>	
					</div>	
				</div>
								<!-- A产品 -->
								<!-- B产品 -->
				<div id="bpro">
					<div class="baTopNo" id="bpro1">
						<span>微刊 </span>
					</div>
					<div class="baBody" id="bpro2">
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">资源类型：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="sourcetype">
													<c:if test="${fn:contains(contract.productb.sourcetype,'1')}">
													<input type="checkbox" value="1" id="sourcetype" name="productb.sourcetype" checked=""/>新闻</c:if>
												</label>
												<label class="checkbox-inline" for="sourcetype">
													<c:if test="${fn:contains(contract.productb.sourcetype,'2')}">
													<input type="checkbox" value="2" id="sourcetype" name="productb.sourcetype" checked=""/>通知</c:if>
												</label>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label" for="-NaN">服务方式：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<label class="checkbox-inline" for="servetype1">
													<c:if test="${fn:contains(contract.productb.servetype,'1')}">
													<input type="checkbox" value="1" id="servetype1" name="productb.servetype" checked=""/>微信接口对接</c:if>
												</label>
												<label class="checkbox-inline" for="servetype2">
													<c:if test="${fn:contains(contract.productb.servetype,'2')}">
													<input type="checkbox" value="2" id="servetype2" name="productb.servetype" checked=""/>微信公共号授权</c:if>
												</label>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">运营方式：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<select class="form-control" name="productb.businesstype">
													<option value="1" <c:if test="${contract.productb.businesstype ==1}">selected=""</c:if>/>自运营</option>
													<option value="2" <c:if test="${contract.productb.businesstype ==2}">selected=""</c:if>/>代理运营</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">微刊地址：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productb.weixinaddress" id="weixinaddress" class="form-control" value="${contract.productb.weixinaddress }"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管账号：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productb.username" id="productb.username" class="form-control"  value="${contract.productb.username }"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管密码：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productb.password" id="productb.password" class="form-control" value="${contract.productb.password }"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="30" name="productb.remark">${contract.productb.remark }</textarea>
												<input type="hidden" name="productb.id" value="${contract.productb.id }"/>
												<input type="hidden" name="productb.coid" value="${contract.productb.coid }"/>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>	
					</div>	
				</div>
								<!-- B产品 -->
								<!-- C产品 -->
				<div id="cpro">
					<div class="baTopNo" id="cpro1">
						<span>微博公共号 </span>
					</div>
					<div class="baBody" id="cpro2">
						<div class="row form-body form-horizontal m-t">
							<div class="col-sm-6">
								<div class="ibox float-e-margins">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-sm-3 control-label">网管账号：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="hidden" name="productc.id" value="${contract.productc.id }"/>
												<input type="hidden" name="productc.coid" value="${contract.productc.coid }"/>
												<input type="text" name="productc.username" id="productc.username" class="form-control" value="${contract.productc.username }"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">网管密码：<span style="color:red">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="productc.password" id="productc.password" class="form-control" value="${contract.productc.password }"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">备注：</label>
											<div class="col-sm-9">
												<textarea rows="5" cols="30" name="productc.remark">${contract.productc.remark }</textarea>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>	
					</div>	
				</div>
								<!-- C产品 -->
					
					<div class="baBody" id="baBodysubmit">
						<table>
							<tr class="bbD">
								<td class="td"></td>
								<td><input type="submit" value="确认" id="button" /> <input
									type="reset" value="重置" id="button" /></td>
							</tr>
						</table>
					</div>
				</form:form>
			</div>

			<!-- 上传广告页面样式end -->
		</div>
	</div>
	<script >
	$(function() {
		//产品显示
		if($("#atype").attr('checked')){
			$("#apro").show();
		}
		if($("#btype").attr('checked')){
			$("#bpro").show();
		}
		if($("#ctype").attr('checked')){
			$("#cpro").show();
		}
		$("#atype").on("click", function() {
			if (this.checked) {
				$("#apro").show();
			} else {
				$("#apro").hide();
			}
		});
		$("#btype").on("click", function() {
			if (this.checked) {
				$("#bpro").show();
			} else {
				$("#bpro").hide();
			}
		});
		$("#ctype").on("click", function() {
			if (this.checked) {
				$("#cpro").show();
			} else {
				$("#cpro").hide();
			}
		});
		//JS验证
		$("#ausername").blur(
				function() {
					if (required($(this), '用户名不能为空')
							&& minLength($(this), 4, '姓名最小长度为4')
							&& maxLength($(this), 20, '姓名最大长度为20'))
						;
				});
		$("#apassword").blur(
				function() {
					if (required($(this), '密码不能为空')
							&& minLength($(this), 4, '密码最小长度为4')
							&& maxLength($(this), 20, '密码最大长度为20'))
						;
				});
		$("#busername").blur(
				function() {
					if (required($(this), '用户名不能为空')
							&& minLength($(this), 4, '姓名最小长度为4')
							&& maxLength($(this), 20, '姓名最大长度为20'))
						;
				});
		$("#bpassword").blur(
				function() {
					if (required($(this), '密码不能为空')
							&& minLength($(this), 4, '密码最小长度为4')
							&& maxLength($(this), 20, '密码最大长度为20'))
						;
				});
		$("#cusername").blur(
				function() {
					if (required($(this), '用户名不能为空')
							&& minLength($(this), 4, '姓名最小长度为4')
							&& maxLength($(this), 20, '姓名最大长度为20'))
						;
				});
		$("#cpassword").blur(
				function() {
					if (required($(this), '密码不能为空')
							&& minLength($(this), 4, '密码最小长度为4')
							&& maxLength($(this), 20, '密码最大长度为20'))
						;
				});
		$("#oname").blur(
				function() {
					if (required($(this), '名称不能为空')
							&& minLength($(this), 2, '机构最小长度为2'))
						;
				});
		$("#autoComplete").blur(
				function() {
					if (required($(this), '机构名称不能为空')
							&& minLength($(this), 2, '机构最小长度为2'))
						;
				});
		$("#amount").blur(
				function() {
					if (checkNeedscore($(this),1000,100000000,'金额不低于1000')
							&& minLength($(this), 4, '最小长度为4'))
							;
				});
		$("#amount").blur(
				function() {
					if (required($(this), '金额不能为空')
							&& minLength($(this), 4, '最小为4位')
							&& maxLength($(this), 20, '最大长度为20'))
						;
				});
		$("#signdate").blur(function() {
			if (required($(this), '时间不能为空'))
				;
		});
		$("#deadline").blur(function() {
			if (required($(this), '时间不能为空'))
				;
		});
		$("#begindate").blur(function() {
			if (required($(this), '时间不能为空'))
				;
		});
		$("#enddate").blur(
				function() {
					if (required($(this), '时间不能为空')
							&& checkStartLessEndDate($("#begindate"),
									$(this), '起始时间 不大于 日期结束时间'))
						;
				});
		$("#begintime").mouseup(function() {
			if (required($(this), '时间不能为空'))
				;
		});
		//暂时先不做网址判断
		$("#html").blur(function() {
			if (required($(this), '网址不能为空'))
				;
		});
		$("#concurrencylevel").blur(function() {
			if (required($(this), '不能为空'))
				;
		});
		$("#weixinaddress").blur(function() {
			if (required($(this), '地址不能为空'))
				;
		});
		$("#aset").blur(function() {
			if (required($(this), '不能为空'))
				;
		});
		$("#bset").blur(function() {
			if (required($(this), '不能为空'))
				;
		});
	});
	function checkform() {
		haveError = false; //全局错误信息变量, 如果有错误,变量值会变成ture  ,再验证完所有之后再判断,是否要提交表单
		var adisplay = $('#apro').css('display');
		var bdisplay = $('#bpro').css('display');
		var cdisplay = $('#cpro').css('display');
		$("#bset").blur();
		$("#aset").blur();
		$("#oname").blur();
		$("#amount").blur();
		$("#autoComplete").blur();
		$("#signdate").mouseup();
		$("#deadline").mouseup();
		$("#begindate").mouseup();
		$("#enddate").mouseup();
		 if(adisplay != 'none'){
			 $("#ausername").blur();
			 $("#apassword").blur();
			$("input:checkbox[name='netfunction']:checked").length > 0;
			$("#begintime").mouseup();
			$("#html").blur();
			$("#concurrencylevel").blur();
		}
		if(bdisplay != 'none'){
			 $("#busername").blur();
			 $("#bpassword").blur();
			$("input:checkbox[name='sourcetype']:checked").length > 0;
			$("input:checkbox[name='servetype']:checked").length > 0;
			$("#weixinaddress").blur();
		} 
		if(cdisplay != 'none'){
			 $("#cusername").blur();
			 $("#cpassword").blur();
		}
		
		
		if (!haveError) {
			return true;
		} else {
			alert("请填写完整");
			return false;
		}
	}
	</script>

</body>
</html>